package com.xm.xmapp.tools;

import android.os.CountDownTimer;
import android.os.Handler;

public class TimeUtil extends CountDownTimer {
	private TimeListener timeListener;

	public TimeUtil(long millisInFuture, long countDownInterval) {
		super(millisInFuture, countDownInterval);
	}

	@Override
	public void onFinish() {
		if (timeListener != null)
			timeListener.timeFinish();
	}

	@Override
	public void onTick(long arg0) {

		if (timeListener != null)
			timeListener.timeOnTick(arg0);
	}

	public TimeListener getTimeListener() {
		return timeListener;
	}

	public void setTimeListener(TimeListener timeListener) {
		this.timeListener = timeListener;
	}

	public interface TimeListener {
		public void timeFinish();

		public void timeOnTick(long time);
	}

	public void startTark() {
		new Handler().postDelayed(new Runnable() {

			@Override
			public void run() {
				start();
			}
		}, 5000);
	}

}
